include config/project.cfg
include config/basic.cfg


#- 编译规则
all: $(OUT)/$(TARGET).elf $(OUT)/$(TARGET).hex $(OUT)/$(TARGET).bin
	@echo "#-------------------------#"
	@echo "# Compile successfully!!! #"
	@echo "#-------------------------#"

$(OUT_OBJ)/%.o: %.c Makefile | $(OUT_OBJ)
	@echo "CC $@"
	@$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(OUT_OBJ)/$(notdir $(<:.c=.lst)) $< -o $@
 
$(OUT_OBJ)/%.o: %.s Makefile | $(OUT_OBJ)
	@echo "AS $@"
	@$(AS) -c $(ASFLAGS) $< -o $@

$(OUT)/$(TARGET).elf: $(OBJECTS) Makefile
	@echo "CC $@"
	@$(CC) $(OBJECTS) $(LDFLAGS) -o $@
	@echo "SZ $@"
	@$(SZ) $@

$(OUT)/%.hex: $(OUT)/%.elf | $(OUT)
	@echo "HEX $@"
	@$(HEX) $< $@

$(OUT)/%.bin: $(OUT)/%.elf | $(OUT)
	@echo "BIN $@"
	@$(BIN) $< $@


include config/misc.cfg
-include $(wildcard $(OUT)/*.d)